CREATE PROCEDURE coreWFProcessDeleteByDefinitionID
(
	@id	int
)
AS
	
	DECLARE @ProcessID int;
	
	DECLARE scr_procs CURSOR FOR
		SELECT PK_ID FROM WFProcess WHERE FK_DefinitionID=@id;
		
	OPEN scr_procs;
	FETCH NEXT FROM scr_procs INTO @ProcessID;
	
	WHILE @@FETCH_STATUS = 0
	BEGIN
		EXEC coreWFProcessDeleteByID @ProcessID;
		FETCH NEXT FROM scr_procs INTO @ProcessID;
	END

	CLOSE scr_procs;
	DEALLOCATE scr_procs;